import React, { useState } from 'react';
import './index.less';
import { history } from 'umi';
export default function Good(props: {
  name: string;
  price: number;
  tag: string;
  desc: Array<string>;
  imgs: string;
  id: string;
  fid: string;
  _id: string;
}) {
  const [name, setname] = useState('哈哈哈哈');
  const [price, setprice] = useState(15.2);
  const [tag, settag] = useState('嘎嘎多人买');
  const [desc, setdesc] = useState(['aaaa', 'bbbbbbbbbbbb', 'cccccccccccccc']);
  function go(id, fid) {
    console.log(id, 'id121212');

    history.push({
      pathname: '/Cdetails',
      state: {
        id: id,
        fid: fid,
      },
    });
  }

  return (
    <div className="agood" onClick={() => go(props.id, props.fid)}>
      {/* <div className="agood" onClick={() => go(props._id)}> */}
      <img src={props.imgs} alt="" />
      <div className="gooddesc">
        <p>
          {props.name}&nbsp;&nbsp;
          {props.desc.map((item, index) => (
            <span key={index}>{item}&nbsp;&nbsp;</span>
          ))}
        </p>
        <span className="goodtag">{props.tag}</span>
        <p className="goodprice">￥{props.price.toFixed(2)}</p>
      </div>
    </div>
  );
}
